package com.keepers.repair.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * auth aboom
 * date 2018/11/17
 */
public class TimeUtils {

    public static String getPlacePatrolTime(String shouldTime, String normal, String earlyTime) {
        String startTime = "--:--";
        if (shouldTime == null || shouldTime.equals("") ||
                normal == null || normal.equals("") ||
                earlyTime == null || earlyTime.equals("")) {
            return startTime;
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        Date date = new Date();
        String time = sdf.format(date);
        time = time.substring(0, 8) + shouldTime.substring(0, 2) + shouldTime.substring(3) + time.substring(12);
        try {
            date = sdf.parse(time);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        date = new Date(date.getTime() - Integer.parseInt(normal) * 60000 - Integer.parseInt(earlyTime) * 60000);
        time = sdf.format(date);
        startTime = time.substring(8, 10) + ":" + time.substring(10, 12);
        return startTime;
    }
}
